################################################################################
## Purpose: Replication Code for Figure 4 and Table A8
## Project: Missionary Activity, Education, and Long-run Political Development  
## Written by: Soeren J. Henn  
## Last updated: 2025-05-22
################################################################################

# This R-Markdown file generates Tables A7 of the paper 
# "Missionary Activity, Education, and Long-run Political Development: Evidence 
# Across Regime Types in Africa" by Soeren J. Henn, Horacio Larreguy, and Carlos
# Schmidt-Padilla. Please see the ReadMe file in the replication archive for 
# further information.

rm(list = ls())

# Add location of replication archive below
rootArg = "~/Dropbox/Missionaries/Replication Archive"

dataDir = paste0(rootArg,"/data")
codeDir = paste0(rootArg,"/code")
outDir = paste0(rootArg,"/output")

library(ggplot2)
library(lfe)
library(stargazer)

################################################################################
########################## Load and prepare data ###############################
################################################################################
setwd(dataDir)

data.grid <- read.csv("grid_data.csv")
reg.river <- felm(dioceses_boundary ~ river_boundary |0|0|0, data =data.grid)
reg.river10 <- felm(dioceses_boundary ~ river10_boundary |0|0|0, data =data.grid)
reg.lakes <- felm(dioceses_boundary ~ lakes_boundary |0|0|0, data =data.grid)
reg.lakes10 <- felm(dioceses_boundary ~ lakes10_boundary |0|0|0, data =data.grid)
reg.watershed <- felm(dioceses_boundary ~ watershed_boundary |0|0|0, data =data.grid)

reg.pcs <- felm(dioceses_boundary ~ pcs_boundary + river_boundary + lakes_boundary + watershed_boundary |0|0|0, data =data.grid)

stargazer(reg.river,reg.river10,reg.lakes,reg.lakes10,reg.pcs, type = "latex")
stargazer(reg.watershed)